#include "LogHandler.h"
#include "3300_gm.pb.h"


int LogHandler::ProcessPacket(CHostBase* host, SocketHandler * pHandler, NETInputPacket* inputPkg)
{
    int cmd = inputPkg->GetCmdType();
    // log_debug("cmd=0x%x,  svid=%d, ", inputPkg->GetCmdType(), pHandler->getId());
    switch (cmd)
    {
        case gm::GM_MSG_ID_LOG_LVL_UPDATE_PUSH:
            log_debug("OnLogLvlUpdate init");
            OnLogLvlUpdate(host, pHandler, inputPkg);
            break;
        default:
            // log_error("cmd=0x%x,  svid=%d, err no proc", cmd, pHandler->getId());
            return -1;
    }
    return 0;
}

int LogHandler::OnLogLvlUpdate(CHostBase* host, SocketHandler * pHandler, NETInputPacket* inputPkg)
{
    int cmd = inputPkg->GetCmdType();
    // log_debug("cmd=0x%x,  svid=%d, ", inputPkg->GetCmdType(), pHandler->getId());
    if (gm::GM_MSG_ID_LOG_LVL_UPDATE_PUSH != cmd)
    {
        return -1;
    }
	gm::LogLevelUpdatePush push;
	if (!inputPkg->parsePb(&push))
	{
		log_error("parser gm::LogLevelUpdatePush failed");
	}
    log_info("push:%s", push.ShortDebugString().c_str());
	set_log_level(push.log_lvl());
    return 0;
}





